package org.alex.nettychat.netty.custom.console;

import io.netty.channel.Channel;
import org.alex.nettychat.netty.custom.protocol.CreateGroupRequestPacket;

import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

/**
 * 创建群里分组
 * @author : alex
 */
public class CreateGroup implements ConsoleCommand {
    @Override
    public void exec(Scanner scanner, Channel channel) {
        CreateGroupRequestPacket createGroupRequestPacket = new CreateGroupRequestPacket();
        System.out.println("[拉人群聊] 请输入userId列表(用,隔开):");
        String userIds = scanner.nextLine();
        createGroupRequestPacket.setUserIdList(Arrays.stream(userIds.split(",")).map(Integer::valueOf).collect(Collectors.toList()));
        channel.writeAndFlush(createGroupRequestPacket);
    }
}
